﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WindowsFormsApp2
{
    public class Dbhelper
    {
        
        public static DataTable GetdataTable(string sql)
        {   string conString = "server =. ; uid =sa ;pwd =123456 ; database =Schools";
            string sqlstring = "select * from Students";

            SqlConnection Connection = new SqlConnection(conString);
            
            SqlDataAdapter Adapter = new SqlDataAdapter(sqlstring , Connection);
            
            Connection.Open();
            DataTable dt = new DataTable();
            Adapter.Fill(dt);
            return dt;
        }
        public static int AddOrEditSave(string sql)
        {
            SqlConnection sqlConnection = new SqlConnection(conString);
            SqlCommand sqlCommand = new SqlCommand(sql, sqlConnection);
            sqlConnection.Open();
            return sqlCommand.ExecuteNonQuery();
        }
}
